<template>
	<view class="content">
		<view class="item">
			<view class="title">
				<view class="shopname">桌号：{{ data.deskNo || '未知' }}</view>
				<view class="l shopname">订单号：{{ data.item.mchOrderNo }}</view>
				<view class="r paytype">{{ ordersta(data.item.payType) }}</view>
			</view>
			<view class="goods">
				<view class="vipinfo">
					<view class="l header">
						<image class="head" :src="data.memberId.avatarUrl || '../../static/head.png'" mode="" />
						<image class="V" src="../../static/logo.png" />
					</view>
					<view class="l">
						<view class="username">{{ data.memberId.name }}</view>
						<view class="phone">手机号：{{ data.memberId.mobile }}</view>
						<view class="phone">会员ID：{{ data.memberId.mchMemberNo }}</view>
					</view>
				</view>
				<view class="good_item" v-for="(item, index) in data.item.ordersItemBOList" :key="index">
					<view class="good_info l">
						<view class="good_name">{{ item.skuName }}</view>
						<view class="good_specs">{{ item.remark || '无备注' }}</view>
					</view>
					<view class="good_cp r">
						<view class="good_price">￥{{ item.amount }}</view>
						<view class="good_count">共{{ item.goodsCount }}件</view>
					</view>
				</view>
			</view>
			<view class="time">购买时间：{{ data.item.createdDate }}</view>
			<view class="good_pay">
				<text>共{{ data.item.goodsCount }}件</text>
				<text style="font-size: 28rpx; color: #28282b">实际付款：￥{{ data.item.payAmount }}</text>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
import { reactive } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { err, toast } from '@/utils/uniapi';
import { api } from '@/api/mop_api';
import { ordersta } from '@/utils/utils';
const data = reactive({
	id: '',
	item: { id: '', payType: '', createdDate: '', ordersItemBOList: [] as any[], goodsCount: '', payAmount: '' },
	memberId: { avatarUrl: '', name: '', mobile: '', id: '' },
	show: false,
	devices: [],
	connected: false,
	chs: [],
	deskNo: ''
});
onLoad((e: any) => {
	data.id = e.id;
	data.memberId = JSON.parse(e.memberId);
});
onShow(() => {
	getord();
});
async function getord() {
	try {
		const { id } = data;
		const res = await api.orderget({ id });
		if (res.respCode === 200) {
			const item = JSON.parse(res.source);
			data.item = item;
			getboard(item.deskId);
		} else {
			toast(res.msg);
		}
	} catch (error) {
		err(error);
		throw error;
	}
}
async function getboard(id: string) {
	try {
		const res = await api.board_get({ id });
		if (res.respCode === 200) {
			const desk = JSON.parse(res.source);
			data.deskNo = desk.name;
		}
	} catch (e) {
		//TODO handle the exception
	}
}
</script>

<style scoped>
.list {
	width: 100%;
}
.item {
	width: 710rpx;
	/* height: 608rpx; */
	background: #ffffff;
	border-radius: 24rpx 24rpx 24rpx 24rpx;
	opacity: 1;
	margin: 24rpx auto;
	padding: 16rpx 40rpx 30rpx 14rpx;
	box-sizing: border-box;
}
.title {
	width: 656rpx;
	overflow: hidden;
	padding-bottom: 8rpx;
	border-bottom: 2rpx solid #ebebf0;
	margin: 0 auto;
}
.shopname {
	font-size: 28rpx;
	font-family: Inter-Regular, Inter;
	font-weight: 400;
	color: #28282b;
	width: 282rpx;
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
}
.stats {
	font-size: 28rpx;
	font-family: Inter-Regular, Inter;
	font-weight: 400;
}
.vipinfo {
	overflow: hidden;
	width: 100%;
	font-size: 26rpx;
	margin-top: 20rpx;
	border-bottom: 2rpx solid #ccc;
}
.header {
	position: relative;
}
.V {
	width: 30rpx;
	height: 30rpx;
	position: absolute;
	top: 0;
	left: 0;
}
.head {
	width: 110rpx;
	height: 110rpx;
	background: #707070;
	border-radius: 50%;
	margin-right: 26rpx;
}
.goods {
	width: 656rpx;
	margin: 0 auto;
	border-bottom: 2rpx solid #ebebf0;
	padding-bottom: 12rpx;
}
.good_item {
	margin-top: 12rpx;
	width: 100%;
	height: 108rpx;
	overflow: hidden;
}
.good_img {
	width: 108rpx;
	height: 108rpx;
	background-color: #808089;
	border-radius: 24rpx;
	margin-left: 6rpx;
}
.good_info {
	width: 292rpx;
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
	margin-left: 18rpx;
}
.good_name {
	font-size: 28rpx;
	font-family: Inter-Regular, Inter;
	font-weight: 400;
	color: #28282b;
	line-height: 42rpx;
}
.good_specs {
	font-size: 24rpx;
	font-family: Source Han Sans CN-Regular, Source Han Sans CN;
	font-weight: 400;
	color: #999999;
	line-height: 42rpx;
}
.good_cp {
	line-height: 42rpx;
}
.good_price {
	font-size: 28rpx;
	font-family: Source Han Sans CN-Regular, Source Han Sans CN;
	font-weight: 400;
	color: #3d3d3d;
}
.good_count {
	font-size: 24rpx;
	font-family: Source Han Sans CN-Regular, Source Han Sans CN;
	font-weight: 400;
	color: #999;
}
.time {
	font-size: 20rpx;
	font-family: Source Han Sans CN-Regular, Source Han Sans CN;
	font-weight: 400;
	color: #999999;
	line-height: 42rpx;
}
.good_pay {
	text-align: right;
	font-size: 24rpx;
	font-family: Source Han Sans CN-Regular, Source Han Sans CN;
	font-weight: 400;
	color: #999999;
	line-height: 42rpx;
}
.good_btn {
	overflow: hidden;
	margin-top: 8rpx;
}
.open {
	width: 142rpx;
	height: 54rpx;
	border-radius: 32rpx;
	border: 2rpx solid #d8d8d8;
	text-align: center;
	line-height: 54rpx;
	font-size: 24rpx;
	font-family: Source Han Sans CN-Medium, Source Han Sans CN;
	font-weight: 500;
	color: #999999;
	margin-right: 24rpx;
}
.again {
	width: 142rpx;
	height: 54rpx;
	background: #eb5757;
	border-radius: 32rpx;
	text-align: center;
	line-height: 54rpx;
	font-size: 24rpx;
	font-family: Source Han Sans CN-Medium, Source Han Sans CN;
	font-weight: 500;
	color: #ffffff;
}
.radio {
	width: 710rpx;
	margin: 0 auto;
}
.btn {
	width: 652rpx;
	height: 80rpx;
	background: #e30514;
	border-radius: 56rpx 56rpx 56rpx 56rpx;
	margin: 0 auto;
	font-size: 32rpx;
	font-family: Source Han Sans CN-Medium, Source Han Sans CN;
	font-weight: 500;
	color: #ffffff;
	text-align: center;
	line-height: 80rpx;
}
.devices_summary {
	margin-top: 30px;
	padding: 10px;
	font-size: 16px;
}
.device_list {
	height: 300px;
	margin: 50px 5px;
	margin-top: 0;
	border: 1px solid #eee;
	border-radius: 5px;
	width: auto;
}
.device_item {
	border-bottom: 1px solid #eee;
	padding: 10px;
	color: #666;
}
.device_item_hover {
	background-color: rgba(0, 0, 0, 0.1);
}
.connected_info {
	position: fixed;
	bottom: 0;
	width: 100%;
	background-color: #f0f0f0;
	padding: 10px;
	padding-bottom: 20px;
	margin-bottom: env(safe-area-inset-bottom);
	font-size: 14px;
	min-height: 100px;
	box-shadow: 0px 0px 3px 0px;
}
.connected_info .operation {
	position: absolute;
	display: inline-block;
	right: 30px;
}
</style>
